<template>
	<view class="content_list" style="background: #141414;">
		<view class="cu-list menu">
			<view class="cu-item">
				<view class="content">
					<text class="serve_title">个人信息</text>
				</view>
			</view>
			<view class="cu-item arrow" @click="queryHouseInfo">
				<view class="content">
					<text class="iconfont icon-fangwuxinxi iconColor iconFontSize"></text>
					<text class="text-grey">房屋信息</text>
				</view>
			</view>

			<view class="cu-item arrow" @click="billQuery">
				<view class="content">
					<text class="iconfont icon-zhangdanxinxi iconColor iconFontSize"></text>
					<text class="text-grey">账单信息</text>
				</view>
			</view>

			<view class="cu-item arrow" @click="houseInfo">
				<view class="content">
					<text class="iconfont icon-jiatingchengyuan iconColor iconFontSize"></text>
					<text class="text-grey">家人信息</text>
				</view>
			</view>

			<view class="cu-item arrow" @click="pointsQuery">
				<view class="content">
					<text class="iconfont icon-jifenchaxun iconColor iconFontSize"></text>
					<text class="text-grey">积分查询</text>
				</view>
			</view>


			<view class="cu-item arrow" @click="coupons">
				<view class="content">
					<text class="iconfont icon-youhuiquan2 iconColor iconFontSize"></text>
					<text class="text-grey">优惠券查询</text>
				</view>
			</view>

			<view class="cu-item arrow" @click="electricityQuery">
				<view class="content">
					<text class="iconfont icon-fangwuxinxi iconColor iconFontSize"></text>
					<text class="text-grey">电表度数查询</text>
				</view>
			</view>

			<view class="cu-item arrow" @click="mySettings()">
				<view class="content">
					<text class="cuIcon-settings text-gray iconColor"></text>
					<text class="text-grey">设置</text>
				</view>
			</view>
			<view class="cu-item arrow" @tap="_logout()" v-if="login">
				<view class="content">
					<text class="cuIcon-circlefill text-yellow"></text>
					<text class="text-grey">退出登录</text>
				</view>
			</view>
		</view>

		<view class="cu-modal" :class="logoutUser==true?'show':''">
			<view class="cu-dialog">
				<view class="cu-bar bg-white justify-end">
					<view class="content">退出系统</view>
					<view class="action" @tap="_cancleLogout()">
						<text class="cuIcon-close text-red"></text>
					</view>
				</view>
				<view class="padding-xl">
					您确认退出系统吗？
				</view>
				<view class="cu-bar bg-white justify-end">
					<view class="action margin-0 flex-sub  solid-left" @tap="_cancleLogout()">取消</view>
					<view class="action margin-0 flex-sub text-green solid-left" @tap="_doLogoutUser()">确定</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import context from '@/lib/java110/Java110Context.js';
	const factory = context.factory; //获取app实例
	const constant = context.constant;
	export default {
		name: "my-system",
		data() {
			return {
				logoutUser: false,
				login: true
			};
		},
		created() {
			this._judgeHasLogin();
		},
		methods: {
			billQuery(){
			// 账单查询
				uni.navigateTo({
					url: "../../pagesB/mineInfoQuery/billTypeList"
				})
			},

			// 房屋信息查询
			queryHouseInfo() {
				uni.navigateTo({
					url: "../../pagesB/my/myHouse"
				})
			},
			// 积分查询
			pointsQuery() {
				uni.navigateTo({
					url: "../../pagesB/mineInfoQuery/pointsQuery"
				})
			},
			// 电表度数查询
			electricityQuery() {
				uni.navigateTo({
					url: "../../pagesB/mineInfoQuery/electricityQuery"
				})
			},
			//优惠券
			coupons: function(_item) {
				uni.navigateTo({
					url: '/pagesA/myAccount/myCoupons',
				})
			},
			// 家庭信息
			houseInfo: function() {
				uni.navigateTo({
					url: '/pagesA/familyList/familyList'
				})
			},
			_judgeHasLogin: function() {
				let _that = this; //查询用户信息
				if (!_that.ckeckUserInfo()) {
					_that.login = false;
					return;
				}
				_that.login = true;
			},
			ckeckUserInfo: function() {
				return context.checkLoginStatus();
			},
			// 设置
			mySettings: function() {
				// if (!this.ckeckUserInfo()) {
				// 	uni.navigateTo({
				// 		url: '/pages/showlogin/showlogin'
				// 	}, () => {
				// 		this.refreshPageLoginInfo();
				// 	});
				// 	return;
				// }
				uni.navigateTo({
					url: '/pagesC/settings/settings',
				});
			},
			//退出系统
			_logout: function() {
				this.logoutUser = true;
			},
			_cancleLogout: function() {
				this.logoutUser = false;
			},
			_doLogoutUser: function() {
				let _data = {
					token: uni.getStorageSync('token')
				}
				let that = this;
				uni.request({
					url: constant.url.userLogout,
					header: context.getHeaders(),
					method: "POST",
					data: _data,
					success: function(res) {
						if (res.statusCode != 200) {
							uni.showToast({
								icon: "none",
								title: res.data
							});
							return;
						}
						let wAppId = uni.getStorageSync(constant.mapping.W_APP_ID);
						uni.clearStorageSync();
						if (wAppId != null && wAppId != undefined && wAppId != '') {
							uni.setStorageSync(constant.mapping.W_APP_ID, wAppId);
						}
						that.logoutUser = false;
						uni.navigateTo({
							url: '/pagesC/login/login'
						});
					},
					fail: function(error) {
						// 调用服务端登录接口失败
						uni.showToast({
							title: '调用接口失败'
						});
						console.log(error);
					}
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
	.content_list {
		padding: 0rpx 20rpx 0rpx 20rpx;
		background: #141414 ;
		padding-bottom: 20rpx;

		.serve_title {
			line-height: 42upx;
			font-size: 30upx;
			font-weight: 600;
			color: white;
			padding: 0rpx;
		}
	}

	.cu-list {
		// border-radius: 20rpx 20rpx 20rpx 20rpx;
	}

	.contact_hoking {
		float: right;
		margin-right: 40rpx;
	}

	.cu-list.menu>.cu-item {
		position: relative;
		display: flex;
		padding: 0 30rpx;
		min-height: 100rpx;
		background-color: #141414;
		justify-content: space-between;
		align-items: center;
	}

	.iconFontSize {
		margin-right: 10rpx;
		font-size: 40rpx;
	}
</style>
